package com.xbongbong.paas.config;

import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.help.factory.OperatorFieldHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @author 吴峰
 * @date 2022/03/09 14:59
 */
@Configuration
public class BusinessRuleConfig {

    @Autowired
    private Map<String, OperatorFieldHandler> operatorFieldHandlerMap;

    @Bean("operatorFieldHandlerMap")
    public Map<Integer, OperatorFieldHandler> initOperatorFieldHandlerMap() {
        Map<Integer, OperatorFieldHandler> resultMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        this.operatorFieldHandlerMap.forEach((key, item)->{
            item.fieldType().forEach(filedType->{
                resultMap.put(filedType, item);
            });
        });
        return resultMap;
    }
}
